

#include "wx/wxprec.h"
#include <wx/wx.h>
#include "wxFormBuilder.h"
#include  "MainFrame.h"
#include   "XMain.h"
#include  "xEngineEdit.h"



#ifdef _DEBUG
#pragma comment(lib,"xMain_d.lib")
#else	
#pragma comment(lib,"xMain.lib")
#endif





DECLARE_APP(MyApp)

IMPLEMENT_APP(MyApp)



bool:: MyApp::OnInit()
{

	m_pframe = new MainFrame(NULL);

	m_pframe->Show(true);
	this->SetTopWindow(m_pframe);

	/*
	HWND hand = (HWND)(m_pframe->m_RightPanel->GetHandle());
	wxSize size =   m_pframe->m_RightPanel->GetClientSize();

	XE::RenderConfig config(hand,false,size.GetWidth(),size.GetHeight());
	
	XE::xRenderTarget* pTarget =  XE::XEngine::getSingleton().GetRenderSystem()->\
		CreateAttachRenderTarget("attachTarget",config);

	if(pTarget!=NULL)
	{

		XE::xCamera* pCamera =XE::XEngine::getSingleton().GetMainSceneManager()->GetCameraByName("MainCamera");
		if(pCamera!=NULL)
		{
              	pTarget->CreateViewPort("attachatrgetview",pCamera);
		}
	
	}


//*/
	return true;
}


bool   MyApp::ProcessIdle()
{
	 
	wxApp::ProcessIdle();
	if(XE::XEngine::getSingletonPtr()!=NULL)
	{
		XE::XEngine::getSingleton().Render();
	}
	return true;
}



 int MyApp::OnExit()
 {
	if(XE::XEngine::getSingletonPtr()!=NULL)
		 delete  XE::XEngine::getSingletonPtr();

	 return 0;
 }